package 剑指offer_leetcode;

public class 剑指Offer31_栈的压入弹出序列 {
    public boolean validateStackSequences(int[] pushed, int[] popped) {
        int i = 0;
        int j = 0;
        for(int num : pushed){
            pushed[i] = num;
            while(i>=0 && pushed[i]==popped[j]){
                i--;
                j++;
            }
            i++;
        }
        return i==0;
    }
}
